<template>
  <el-dialog
    title="修改"
    close-on-click-modal
    close-on-press-escape
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="120px">
    <el-form-item label="物流公司" >
      <el-select v-model="dataForm.logisticsCompany" placeholder="请选择">
        <el-option label="顺丰快递" value="shunfeng"></el-option>
        <el-option label="韵达快递" value="yunda"></el-option>
        <el-option label="中通快递" value="zhongtong"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="物流单号" prop="relogisticsOrderNoqsn">
      <el-input v-model="dataForm.relogisticsOrderNoqsn" placeholder="请输入物流单号"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" >确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        isdisabled:false,
        visible: false,
        dataForm: {
          id: 0,
          logisticsCompany: '',
          relogisticsOrderNoqsn:''
        },
        dataRule: {
          relogisticsOrderNoqsn: [
            { required: true, message: '请输入修改价格', trigger: 'blur' }
          ],
        },
        // 物流公司映射(数据不明)
        option:[]
      }
    },
    methods: {
      init (item) {
        this.dataForm.id = item.reqsn || 0
        this.dataForm.logisticsCompany = item.logisticsCompany
        this.dataForm.relogisticsOrderNoqsn = item.logisticsOrderNo
        this.visible = true
        // 渲染物流公司映射(数据不明)
        // this.$nextTick(() => {
        //   this.$refs['dataForm'].resetFields()
        //   if (this.dataForm.id) {
        //     this.$http({
        //       url: this.$http.adornUrl(`/course/coursetype/info/${this.dataForm.id}`),
        //       method: 'get',
        //       params: this.$http.adornParams()
        //     }).then(({data}) => {
        //       if (data && data.code === 0) {
        //         this.dataForm.typeDescribe = data.courseType.typeDescribe
        //         this.dataForm.deleted = data.courseType.deleted
        //         this.dataForm.createTime = data.courseType.createTime
        //         this.dataForm.updateTime = data.courseType.updateTime
        //       }
        //     })
        //   }
        // })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.isdisabled=true
            this.$http({
              url: this.$http.adornUrl("/admin/order/delivery"),
              method: "put",
              data: this.$http.adornData({
                logisticsCompany:this.dataForm.logisticsCompany,
                logisticsOrderNo:this.dataForm.relogisticsOrderNoqsn,
                reqsn:this.dataForm.id
              }),
            }).then(({ data }) => {
              if (data && data.code === '200') {
                this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.visible=false;
                     this.$emit('refreshDataList')
                  },
                });
              } else {
                this.$message.error(data.msg);
              }
              this.isdisabled=false
            });
          }
        })
      }
    }
  }
</script>
